

//
//  NamedViewController.m
//  BOSS-SOOC
//
//  Created by apple on 16/8/23.
//  Copyright © 2016年 Gcx. All rights reserved.
//
#define BGCDS  [UIColor colorWithRed:250.0/255 green:250.0/255 blue:250.0/255 alpha:1.0f]
#define _vc_start_postion 64
#define ImageHeight ((SIZEWIDTH-64)/3 - ScaleSize(550)*SCALE6P)

#import "NamedViewController.h"
#import "creatClass/CreatClassViewController.h"
#import "classManager/ClassManagerViewController.h"
#import "HistoryNamedViewController.h"
#import "TodayNamedViewController.h"
#import "TotalViewController.h"

@interface NamedViewController(){
    
    UIView *_view;

}

@end

@implementation NamedViewController

- (void)viewDidLoad{
    
    [super viewDidLoad];
    
    [self setNavBarTitle:@"我要点名"];
    
    [self buildUI];
    
    
}

- (void)buildUI{

    self.view.backgroundColor = BGCDS;
    
    UIImageView *bigImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SIZEWIDTH, SIZEHEIGHT)];
    
    bigImage.image = [UIImage imageNamed:@"我要点名-背景图"];
    
    [self.view addSubview:bigImage];
    
    NSArray *name    = @[@"创建课堂",@"今日点名",@"课程管理",@"历史点名",@"统计"];
    NSArray *normarl = @[@"我要点名-创建课堂",@"我要点名-今日点名",@"我要点名-课程管理",@"我要点名-历史点名",@"我要点名-统计"];
    NSArray *height  = @[@"我要点名-创建课堂pass",@"我要点名-今日点名pass",@"我要点名-课程管理pass",@"我要点名-历史点名pass",@"我要点名-统计pass"];
    
    
    for (int i = 0; i < 5; i++) {
        
       _view = [self viewWithFrame:CGRectMake((i%2)*SIZEWIDTH/2, _vc_start_postion+(i/2)*(SIZEHEIGHT-64)/3, SIZEWIDTH/2-1, (SIZEHEIGHT-64)/3-1)];
        
        [self.view addSubview:_view];
        

        UIButton *btn = [self normalImage:normarl[i] andHeightImage:height[i]];
        UILabel *label = [self labelWithFrame:CGRectMake(10, CGRectGetMaxY(btn.frame)+ScaleSize(30), SIZEWIDTH/2-20, 15) andTitle:name[i]];
        
        [_view addSubview:btn];
        [_view addSubview:label];
        btn.tag = 100+i;
    }

}



- (UIView *)viewWithFrame:(CGRect)frame{
    
    UIView *view = [[UIView alloc]init];
    
    view.frame = frame;
    
    view.backgroundColor = [UIColor clearColor];
    
    return view;
    
}

- (UILabel *)labelWithFrame:(CGRect)frame andTitle:(NSString *)title{

    UILabel *label = [[UILabel alloc]init];

    label.frame = frame;
    label.text = title;
    label.textAlignment = NSTextAlignmentCenter;
    label.font = NormalFont(42);
    label.textColor = Color999999;

    return label;
}


- (UIButton *)normalImage:(NSString *)normalImage andHeightImage:(NSString *)heightImage{

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(SIZEWIDTH/4-ImageHeight/2, SIZEHEIGHT/6-ImageHeight/2- 20, ImageHeight, ImageHeight);
    [btn setBackgroundImage:[UIImage imageNamed:normalImage] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:heightImage] forState:UIControlStateHighlighted];
    
    [btn addTarget :self action:@selector(tapClikedOne:) forControlEvents:UIControlEventTouchUpInside];

    return btn;
}

-(void)tapClikedOne:(UIButton*)sender{

    /**
     *  创建课堂
     */
    if (sender.tag == 100) {
        
        CreatClassViewController *vc = [[CreatClassViewController alloc]init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self navigationCanDragBack:YES];
        
        [self.navigationController pushViewController:vc animated:YES];

    }
    /**
     *  今日点名
     */
    if (sender.tag == 101) {
        
        TodayNamedViewController *vc = [[TodayNamedViewController alloc]init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self navigationCanDragBack:YES];
        
        [self.navigationController pushViewController:vc animated:YES];
        
    }
    /**
     *  课程管理
     */
    if (sender.tag == 102) {
        
        ClassManagerViewController *vc = [[ClassManagerViewController alloc]init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self navigationCanDragBack:YES];
        
        [self.navigationController pushViewController:vc animated:YES];
        
    }
    /**
     *  历史点名
     */
    if (sender.tag == 103) {
        
        HistoryNamedViewController *vc = [[HistoryNamedViewController alloc]init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self navigationCanDragBack:YES];
        
        [self.navigationController pushViewController:vc animated:YES];
        
    }
    /**
     *  统计
     */
    if (sender.tag == 104) {
        
        TotalViewController *vc = [[TotalViewController alloc]init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self navigationCanDragBack:YES];
        
        [self.navigationController pushViewController:vc animated:YES];
        
    }

}

@end
